<template>
	<view class="pd pm200">
		<template v-for="(item,idx) in jnxzcf">
			<view class="cdvcxdvrtecxrt pd pt20 pm20 mt20 ">
				<view class="display-flex" @tap="hf('/pages/enterprise/details?id='+item.id)">
					<view class="dfdsxcfret">
						<frImage :src="item.companyImg"></frImage>
					</view>
					<view class=" flex-1 ml10">
						<view class="">
							<text class="iconfont icon-gongsi"></text>
							<text class="z3 fz26 ml5">{{item.companyName}} </text>
						</view>
						<view class="">
							<text class=" iconfont icon-map z9 fz28"></text>
							<text class="z9 fz24 ml5">{{item.companyAddr}} </text>
						</view>
					</view>
				</view>
				<view class="btm display-flex mt20 pt20 fz30">
					<view class=" flex-1 ls cen brm"  @tap="hf('bjcorporation?id='+item.id)">
						编辑
					</view>
					<view class=" flex-1 red  cen" @tap="dkmxdffdf(idx,item)">
						删除
					</view>
				</view>
			</view>
		</template>
		
		<view class="kcdxvrtxzty pd pm20 bgff pt20">
			<button type="primary" class="fz32" @tap="hf('bjcorporation')">+新增公司</button>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import { onLoad, onReachBottom,onShow } from "@dcloudio/uni-app"
	import { dxrequest, kmxzcf, hf, transferTimeYMD } from "@/util/index.js"
	import frImage from "@/components/fr-image/fr-image.vue"
	const page = ref(1)
	const jnxzcf = ref([])
	const init = async () => {
		uni.showLoading({
			title: "加载中..."
		})
		const { data } = await dxrequest("/api/tmcompany/page", {
			page: page.value,
			limit: 10,
			status: 2,
			isJob: false
		})
		data.list.map(a => {
			jnxzcf.value.push(a)
		})
		uni.hideLoading()
		uni.stopPullDownRefresh();
	}
	

onShow(()=>{
	page.value = 1
	jnxzcf.value = []
	init()
})
	onReachBottom(() => {
		page.value++
		init()
	})
	const dessdf = async (id) => {
		const ret = await dxrequest("/api/tmcompany", [id], "DELETE")
	}
	const dkmxdffdf = (idx, data) => {
		uni.showModal({
			title: "温馨提示！",
			content: "确认删除嘛？删除后无法恢复哦！",
			async success({ confirm }) {
				if (confirm) {
					await dessdf(data.id)
					jnxzcf.value.splice(idx, 1)
				}
			}
		})
	}
</script>

<style scoped>
	.dfdsxcfret {
		width: 100rpx;
		height: 100rpx;
		border-radius: 8rpx;
		border: 2rpx solid #e0e0e0;
		overflow: hidden;
	}
</style>